﻿@model List<BudgetMealsModels.Entities.Recipe>
@if (Model.Count() > 0)
{
<table width="80%">
<tr><th>Name</th><th>Rating</th><th>Summary</th></tr>         
@foreach (var m in Model)
{
    <tr><td>@Html.ActionLink(m.Name, "ShowRecipe", new { controller = "Recipe", Id = m.RecipeID })</td><td style="float:left;width:25px;">@m.Rating</td>
     <td style="width:150px">
     
    @if (Html.Raw(m.Summary).ToString().Replace("<p>", "").Count() > 40)
    {
         @Html.Raw(m.Summary).ToString().Replace("<p>", "").Replace("</p>", "").Replace("<em>", "").Replace("</em>", "").Replace("<strong>", "").Replace("</strong>", "").Replace("<u>", "").Substring(0, 40)@:... 
    }
    else
    {
        @Html.Raw(m.Summary)
    }
    </td>
    @if (Session["CurrentUser"] != null && m.UserCreatedID == (int)Session["CurrentUser"])
    {
    <td class="CRUDbutton" style="width:100px;">
        @Html.ActionLink("Edit Recipe", "Edit", "Recipe", new { userId = (int)Session["CurrentUser"], id = m.RecipeID }, null)
        @*@using (Html.BeginForm("Edit", "Recipe", new { userId=Session["CurrentUser"], Id = m.RecipeID}, FormMethod.Get))
        {
            <input type="submit" value="Edit recipe" />
        }*@
    </td>
    <!--<td class="CRUDbutton">
        @using (Html.BeginForm("Delete", "Recipe", new { id = m.RecipeID, userId = Session["CurrentUser"], redirectURL = Request.Url.PathAndQuery }))
        {
            <input type="submit" value="Delete" />
        }
    </td>
    -->
    <td class="CRUDbutton" style="height:40px;">
        @Html.ActionLink("Add Images...", "AddImage", "Recipe", new { id = m.RecipeID }, null)
        @*@using (Html.BeginForm("AddImage", "Recipe", new { id = m.RecipeID }))
        {
            <input type="submit" value="Add Images..." />
        }*@
    </td>
    }
    </tr>
}
</table>
}
else
{
    <p>There are no recipes!</p>
}
        @Html.ActionLink("Add Recipe...", "Edit", "Recipe", new { userID = Session["CurrentUser"] }, null)

